<template>
  <div class="user-recommend">
    <slot name="introduce">
      <p class="recommend-title">为你推荐</p>
    </slot>
    <div class="recommend-list">
      <div class="recommend-item" v-for="item in recommendList" :key="item.id"
       @click="$router.push('/productDetail/' + item.id)">
        <img
          :src="item.imageHost + item.mainImage"
        />
        <p>
          {{item.subtitle}}
        </p>
        <i>{{item.price}}</i>
      </div>
    </div>
  </div>
</template>

<script>
import { recommend } from "@/api";
export default {
  data() {
    return {
      recommendList: [],
    };
  },
  mounted() {
    recommend((res) => {
      this.recommendList = res.data;
      // console.log(this.recommendList);
    });
  },
};
</script>

<style lang="scss" scoped>
 .recommend-title {
        width: 100%;
        height: 90px;
        padding-left: 20px;
        line-height: 90px;
        background: #fff;
        box-sizing: border-box;
        font-size: 24px;
    }

    .recommend-list {
        display: flex;
        flex-shrink: 0;
        flex-wrap: wrap;
        width: 100%;
        margin-top: 30px;
        padding-bottom: 150px;
        box-sizing: border-box;
        background: #fff;

        .recommend-item {
            display: flex;
            flex-direction: column;
            width: 50%;
            padding: 20px;
            box-sizing: border-box;
            border-bottom: 1px solid #dcdcdc;

            &:nth-child(2n-1) {
                border-right: 1px solid #dcdcdc;
            }

            img {
                width: 100%;
                height: 290px;
                margin: 0 auto;
            }

            p {
                height: 60px;
                padding: 20px 0;
                font-size: 26px;
                line-height: 40px;
                color: #333;
                overflow: hidden;
            }

            i {
                font-style: normal;
                font-size: 32px;
                color: red;
            }
        }
    }

</style>